﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using SES.CMS.BL;
using SES.CMS.DO;

namespace SES.CMS.Module
{
    public partial class ucHomeArticle : System.Web.UI.UserControl
    {
        cmsArticleBL artBL = new cmsArticleBL();
        protected void Page_Load(object sender, EventArgs e)
        {
            rptHomepageArticleDatasource();
            ArticleDatabind();
        }

        protected void rptHomepageArticleDatasource()
        {
            rptHomepageArticle.DataSource = artBL.SelectToHomePage(3);
            rptHomepageArticle.DataBind();
        }

        protected void ArticleDatabind()
        {
            DataTable dtArticle = artBL.SelectToHomePage(1);

            imgArticle.ImageUrl = "/Media/" + dtArticle.Rows[0]["ImageUrl"];
            imgArticle.AlternateText = dtArticle.Rows[0]["Title"].ToString();

            hplTitle.NavigateUrl="/Article/" + dtArticle.Rows[0]["ArticleID"] + "/" + FriendlyUrl(dtArticle.Rows[0]["Title"].ToString());
            hplTitle.Text = dtArticle.Rows[0]["Title"].ToString();

            lblArticleDes.Text = dtArticle.Rows[0]["Description"].ToString();
        }

        public string FriendlyUrl(string s)
        {
            return Ultility.Change_AV(s);
        }
    }
}